﻿Public Class frmTiepNhanGiaoVien

    Private Sub frmTiepNhanGiaoVien_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        cboMon.DataSource = MonHocBUS.SelectAll()
        cboMon.ValueMember = "MAMON"
        cboMon.DisplayMember = "TENMON"
        dgvDSGV.DataSource = GiaoVienBUS.SelectAll()
    End Sub
    Sub LoadDanhSach()
        dgvDSGV.DataSource = GiaoVienBUS.SelectAll()
    End Sub
    Private Sub btnThem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnThem.Click
        Dim gv = New GiaoVienDTO
        gv.MAGIAOVIEN = txtMaGV.Text
        gv.TENGIAOVIEN = txtTenGV.Text
        gv.GIOITINH = IIf(rbNam.Checked, "Nam", "Nữ")
        gv.NGAYSINH = txtNgaySinh.Text
        gv.DIACHI = txtDiaChi.Text
        gv.SODT = txtSoDT.Text
        gv.EMAIL = txtEmail.Text
        gv.MAMON = cboMon.SelectedValue

        Dim re = GiaoVienBUS.Them(gv)
        If re >= 1 Then
            MessageBox.Show("Thêm thành công")
        Else
            MessageBox.Show("Thêm thất bại")
        End If
        LoadDanhSach()
    End Sub

    Private Sub btnReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReset.Click
        txtMaGV.Text = String.Empty
        txtTenGV.Text = String.Empty
        rbNam.Checked = True
        txtNgaySinh.Text = String.Empty
        txtDiaChi.Text = String.Empty
        txtEmail.Text = String.Empty
        txtSoDT.Text = String.Empty
    End Sub

    Private Sub btnThoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnThoat.Click
        Me.Close()
    End Sub
End Class